feat: add -m, -e, and --dry-run CLI mapping flags#48
Merged
Conversation
- Add -m/--mapping flag to load .morph mapping files - Add -e/--expr flag for inline mapping expressions (repeatable) - Add --dry-run flag to validate mappings without executing - Multiple -e flags combine in order; -m and -e can combine (file first) - No mapping flags = straight passthrough conversion - Add 10 integration tests and 7 unit tests covering all TDD scenarios Fixes #19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds mapping support to the CLI with three new flags, completing issue #19.
New Flags
-m / --mapping <file>— Load and apply a.morphmapping file-e / --expr <expression>— Inline mapping expression (repeatable, applied in order)--dry-run— Parse and validate the mapping without executingBehavior
-eflags combine in order-mand-ecan be combined: file operations apply first, then inline expressionsTests
Unit tests (in
src/cli.rs):arg_parsing_mapping_file—-mflag parses correctlyarg_parsing_single_expr— Single-eflagarg_parsing_multiple_expr— Multiple-eflagsarg_parsing_dry_run—--dry-runflagarg_parsing_mapping_and_expr_combined—-m+-etogetherno_mapping_flags_returns_none— No flags → Nonebuild_mapping_from_expr— Builds program from-ebuild_mapping_multiple_exprs_in_order— Multiple exprs produce correct statement countbuild_mapping_invalid_expr_returns_error— Bad syntax → errorbuild_mapping_nonexistent_file_returns_error— Missing file → errorIntegration tests (in
tests/cli_mapping.rs):mapping_file_applies_transformations—-mwith valid filemapping_file_nonexistent_gives_error—-mwith missing filemapping_file_invalid_syntax_gives_parser_error—-mwith bad syntaxsingle_expr_works—-ewith one expressionmultiple_expr_apply_in_order— Multiple-ein sequencemapping_and_expr_combined—-m+-eend-to-enddry_run_valid_mapping_reports_valid—--dry-runwith valid mappingdry_run_invalid_mapping_reports_error—--dry-runwith bad mappingno_mapping_flags_passthrough— Passthrough without mappingfull_integration_json_to_yaml_with_mapping— Full end-to-end with file I/OFixes #19